<template>
        <ul>
            <li 
            v-for="(item, index) in head" 
            @click="selectedIndex = index"
            :class="{ active: index === selectedIndex }"
            >
                {{ item.title }}
            </li>
        </ul>
        <div class="box">
            <div 
            v-for="(item, index) in body"
            :class="{ selected: index === selectedIndex }"
            >
                {{ item.content }}
            </div>
        </div>
        
</template>

<script setup>
import { ref } from 'vue'
const selectedIndex = ref(0)
const head = ref([
    {id: 1,title: 'walk'},
    {id: 2,title: 'tea'},
    {id: 3,title: 'read'}
])
const body = ref([
    {id: 1,content: '跟二桥散步'},
    {id: 2,content: '和二桥喝茶'},
    {id: 3,content: '与二桥读书'}
])
</script>

<style scoped>
* {
    padding: 0;
    margin: 0;
}
ul {
    display: flex;
}
li {
    list-style-type: none;
    height: 30px;
    width: 40px;
    border: 1px solid black;
    display: flex;
    justify-content: center;
    align-items: center;
}
li:hover {
    cursor: pointer;
}
.box {
    height: 60px;
    width: 123px;
    border: 1px solid black;
    display: flex;
    justify-content: center;
    align-items: center;
}
.active {
    background-color: aqua;
}
.box > div {
    display: none;
}
.box .selected {
    display: block;
}
</style>